-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UnbakedModelDeserializer
#4321
base: 1.21.4
Are you sure you want to change the base?
Add UnbakedModelDeserializer
#4321
Conversation
Is load conditions the same thing as resource conditions? if so, https://github.com/FabricMC/fabric/blob/1.21.4/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java#L66-L87 is the implentation. If a type is not specified, the resource is loaded as normal, as if all conditions passed |
|
|
||
import net.fabricmc.fabric.impl.client.model.loading.UnbakedModelDeserializerRegistry; | ||
|
||
public interface UnbakedModelDeserializer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadoc
return UnbakedModelDeserializerRegistry.deserialize(reader); | ||
} | ||
|
||
UnbakedModel deserialize(JsonObject jsonObject, JsonDeserializationContext context) throws RuntimeException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadoc, especially with regards to the context
.
return UnbakedModelDeserializerRegistry.deserialize(reader); | ||
} | ||
|
||
UnbakedModel deserialize(JsonObject jsonObject, JsonDeserializationContext context) throws RuntimeException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why RuntimeException rather than a Gson one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is acceptable for the deserializer to throw any RuntimeException
, such as InvalidIdentifierException
. The vanilla JsonUnbakedModel
deserializer does that.
This pull request introduces the
UnbakedModelDeserializer
interface, which allows overriding the deserialization process of a JSON model file based on itsfabric:type
JSON key.Points to Discuss
elements
,parent
,textures
,ambientocclusion
,display
,gui_light
) be provided? If so, how?UnbakedModelDeserializer
have a method to retrieve itsIdentifier
likeCustomIngredientSerializer
instead of the ID being passed to theregister
method directly?UnbakedModelDeserializer
be generic? It represents a "type" which can create instances, and such classes are almost always generic both in Fabric API and vanilla.TODO